package cz.czu.pef.DataModelling.domainObjects;

import java.util.*;
public class Employee extends IdObjectImpl implements IdObject
{
  private static final long serialVersionUID = 6926802498793427958L;

  private Person person;

	/*
	 * Relations
	 */
	private Set<Company> employers;
	private Set<Role> roles;

	public Employee()
	{
		super();
		person = new Person();
	}

	public Employee(Person person)
	{
		this.setPerson(person);
	}

	public Set<Company> getEmployers()
	{
		return employers;
	}

	public List<Company> getEmployersAsList()
	{
		return new ArrayList<Company>(getEmployers());
	}

	public void addEmployer(Company newEmployer)
	{
		if (employers == null)
			employers = new HashSet<Company>();
		employers.add(newEmployer);
	}

	public Person getPerson()
	{
		return person;
	}

	public void setPerson(Person person)
	{
		this.person = person;
	}

	public Set<Role> getRoles()
	{
		return roles;
	}

	public List<Role> getRolesAsList()
	{
		return new ArrayList<Role>(getRoles());
	}

	public void addRole(Role role)
	{
		if (roles == null)
			roles = new HashSet<Role>();

		roles.add(role);
	}

	
  public void setEmployers(Set<Company> employers)
  {
    this.employers = employers;
  }

  
  public void setRoles(Set<Role> roles)
  {
    this.roles = roles;
  }

  public String toString()
	{
		StringBuilder builder = new StringBuilder();
		builder.append("Employee [person=");
		builder.append(person);
		builder.append(", roles=");
		builder.append(roles);
		builder.append(", toString()=");
		builder.append(super.toString());
		builder.append("]");
		return builder.toString();
	}
}